class User < ActiveRecord::Base
  attr_accessible :name, :email, :password, :password_confirmation, :company_pid, :current_project_id
  has_secure_password
  validates_length_of :password, :in => 6..20, :on => :create
  validates_length_of :password, :in => 6..20, :on => :update
  EMAIL_REGEX = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i
  validates :name, :presence => true, :uniqueness => true, :length => { :in => 3..20 }
  validates :email, :presence => true, :uniqueness => true, :format => EMAIL_REGEX
  
  has_many :project_to_users
  has_many :paintings
  belongs_to :company
end
